#include "qe_log.h"
#include "qe_earlycon.h"

QELOG_DOMAIN("mdm");

#define XLNX_MDM_SR_TX_FIFO_FULL        0x00000008

typedef struct
{
    volatile qe_u32 rxfifo;
    volatile qe_u32 txfifo;
    volatile qe_u32 sr;
    volatile qe_u32 cr;
} xlnx_mdm_reg;

static void xlnx_mdm_earlycon_init(const void *fdt, int offset)
{
}

static void xlnx_mdm_earlycon_putc(qe_ubase base, char c)
{
    xlnx_mdm_reg *reg = (xlnx_mdm_reg *)base;
    
    while (reg->sr & XLNX_MDM_SR_TX_FIFO_FULL)
        ;

    reg->txfifo = c;
}

QE_EARLYCON(xlnx_mdm) = {
	.compatible = "xlnx,mdm",
	.init = xlnx_mdm_earlycon_init,
	.putc = xlnx_mdm_earlycon_putc
};
QE_EARLYCON_FORCE_EXPORT(xlnx_mdm);